package com.heima.behavior.controller.v1;

import com.heima.behavior.service.*;
import com.heima.model.behavior.dtos.*;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "app用户行为接口",value = "app用户行为接口")
@RestController
@RequestMapping("/api/v1/")
public class ApUserBehaviorController {
    @Autowired
    ApLikesBehaviorService apLikesBehaviorService;
    @Autowired
    ApReadBehaviorService apReadBehaviorService;
    @Autowired
    ApUnlikeBehaviorService apUnlikeBehaviorService;
    @Autowired
    ApCollectionBehaviorService apCollectionBehaviorService;
    @Autowired
    ApArticleBehaviorService apArticleBehaviorService;

    @ApiOperation(value = "用户点赞行为",notes = "用户点赞行为")
    @PostMapping("/likes_behavior")
    public ResponseResult likes_behavior(@RequestBody @Validated LikesBehaviorDTO dto){
        return apLikesBehaviorService.like(dto);
    }

    @ApiOperation(value = "用户阅读行为",notes = "用户阅读行为")
    @PostMapping("/read_behavior")
    public ResponseResult read_behavior(@RequestBody @Validated ReadBehaviorDTO dto){
        return apReadBehaviorService.readBehavior(dto);
    }

    @ApiOperation(value = "用户不喜欢行为",notes = "用户不喜欢行为")
    @PostMapping("/un_likes_behavior")
    public ResponseResult un_likes_behavior(@RequestBody @Validated UnLikesBehaviorDTO dto){
        return apUnlikeBehaviorService.unlikeBehavior(dto);
    }

    @ApiOperation(value = "用户收藏行为",notes = "用户收藏行为")
    @PostMapping("/collection_behavior")
    public ResponseResult collection_behavior(@RequestBody @Validated CollectionBehaviorDTO dto){
        return apCollectionBehaviorService.collectBehavior(dto);
    }

    @ApiOperation(value = "文章行为API",notes = "文章行为API")
    @PostMapping("/article/load_article_behavior")
    public ResponseResult articleBehavior(@RequestBody @Validated ArticleBehaviorDTO dto){
        return apArticleBehaviorService.loadArticleBehavior(dto);
    }
}
